<% layout('/layouts/default.html', {title: '进货管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa fa-list-alt"></i> ${text('进货管理')}
			</div>
			<div class="box-tools pull-right">
				<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>
				<% if(hasPermi('phone:phoneCommodity:edit')){ %>
					<a href="${ctx}/phone/phoneCommodity/form" class="btn btn-default btnTool" title="${text('新增商品')}"><i class="fa fa-plus"></i> ${text('新增')}</a>
				<% } %>
			</div>
		</div>
		<div class="box-body">
			<#form:form id="searchForm" model="${phoneCommodity}" action="${ctx}/phone/phoneCommodity/listData" method="post" class="form-inline hide"
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
				<div class="form-group">
					<label class="control-label">商品名称：</label>
					<div class="control-inline">
						<#form:input path="commodityName" maxlength="20" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">型号-款号：</label>
					<div class="control-inline">
						<#form:input path="sytleNumber" maxlength="20" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">单价：</label>
					<div class="control-inline">
						<#form:input path="price" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">数量：</label>
					<div class="control-inline">
						<#form:input path="number" maxlength="11" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">总金额：</label>
					<div class="control-inline">
						<#form:input path="totalPrice" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">进货日期：</label>
					<div class="control-inline">
						<#form:input path="purchaseTime" readonly="true" maxlength="20" class="form-control Wdate-date"
						dataFormat="date" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">业务员编号：</label>
					<div class="control-inline">
						<#form:input path="salesmanCode" maxlength="11" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
				</div>
			</#form:form>
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>
</div>
<% } %>
<script>
// 初始化DataGrid对象
$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	columnModel: [
		{header:'产品厂商', name:'manufacturer.name', index:'m.name', width:150, align:"left", frozen:true},
		{header:'商品名称', name:'commodityName', index:'a.commodity_name', width:150, align:"left"},
		{header:'型号-款号', name:'sytleNumber', index:'a.sytle_number', width:150, align:"left"},
		{header:'单价', name:'price', index:'a.price', width:150, align:"right", formatter: function(val, obj, row, act){
			return js.formatNumber(val, 2, false, ''); // 数值类型格式化 (原始数值, 小数位数, 是否千分位, 默认值，金额情况下设置0.00);
		}},
		{header:'数量', name:'number', index:'a.number', width:150, align:"center"},
		{header:'总金额', name:'totalPrice', index:'a.total_price', width:150, align:"right", formatter: function(val, obj, row, act){
			return js.formatNumber(val, 2, false, ''); // 数值类型格式化 (原始数值, 小数位数, 是否千分位, 默认值，金额情况下设置0.00);
		}},
		{header:'进货日期', name:'purchaseTime', index:'a.purchase_time', width:150, align:"center"},
		{header:'业务员编号', name:'salesmanCode', index:'a.salesman_code', width:150, align:"center"},
		{header:'${text('操作')}', name:'actions', width:120, sortable:false, title:false, formatter: function(val, obj, row, act){
			var actions = [];
			<% if(hasPermi('phone:phoneCommodity:edit')){ %>
				actions.push('<a href="${ctx}/phone/phoneCommodity/form?id='+row.id+'" class="btnList" title="${text('编辑商品')}"><i class="fa fa-pencil"></i></a>&nbsp;');
				if (row.status == Global.STATUS_NORMAL){
					actions.push('<a href="${ctx}/phone/phoneCommodity/disable?id='+row.id+'" class="btnList" title="${text('停用商品')}" data-confirm="${text('确认要停用该商品吗？')}"><i class="glyphicon glyphicon-ban-circle"></i></a>&nbsp;');
				}
				if (row.status == Global.STATUS_DISABLE){
					actions.push('<a href="${ctx}/phone/phoneCommodity/enable?id='+row.id+'" class="btnList" title="${text('启用商品')}" data-confirm="${text('确认要启用该商品吗？')}"><i class="glyphicon glyphicon-ok-circle"></i></a>&nbsp;');
				}
				actions.push('<a href="${ctx}/phone/phoneCommodity/delete?id='+row.id+'" class="btnList" title="${text('删除商品')}" data-confirm="${text('确认要删除该商品吗？')}"><i class="fa fa-trash-o"></i></a>&nbsp;');
			<% } %>
			return actions.join('');
		}}
	],
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
</script>